package com.delayqueue.common.netty.handler;

import com.alibaba.fastjson.JSON;
import com.delayqueue.common.netty.NettyMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class MessageToStringEncoder extends MessageToMessageEncoder<NettyMessage> {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, NettyMessage nettyMessage, List<Object> list) throws Exception {
        list.add(JSON.toJSONString(nettyMessage));
    }
}
